package com.sl.service;


import com.sl.mapper.PaperQuestionsMapper;
import com.sl.pojo.PaperQuestions;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;

import javax.annotation.Resource;
import java.util.List;

@Service
public class PaperQuestionsService  {
    @Resource
    private PaperQuestionsMapper   paperQuestionsMapper;

    public List<PaperQuestions> findAll(){
        return paperQuestionsMapper.selectAll();
    }

    //根据每套试题的ID 。。去题库找对应的题ID
    public List<PaperQuestions> findByPaperId(Integer paperId){
        Example example = new Example(PaperQuestions.class);
        Example.Criteria criteria = example.createCriteria();
        criteria.andEqualTo("paperId",paperId);
        List<PaperQuestions> paperQuestions = paperQuestionsMapper.selectByExample(example);
        return paperQuestions;
    }
    public void addPaperQuestion(PaperQuestions paperQuestions){
        paperQuestionsMapper.insertSelective(paperQuestions);
    }

    public void updatePaperQuestion(PaperQuestions paperQuestions){
        paperQuestionsMapper.updateByPrimaryKeySelective(paperQuestions);
    }

    public void deleted(PaperQuestions paperQuestions){
        paperQuestionsMapper.deleteByPrimaryKey(paperQuestions);
    }
}
